import QtQuick 1.1
import com.nokia.meego 1.0
import QtMobility.systeminfo 1.1

Page {
    id: wifipage

    tools: ToolBarLayout {
        id: tool_only_back
        ToolIcon {
            id: toolIconBack
            iconId: "toolbar-back"
            onClicked: { pageStack.pop(); }
        }
    }


    /*
    Rectangle {
        height: parent.height
        width: parent.width
        anchors.centerIn: parent
        border.color: "blue"

         NetworkInfo {
             id: wlaninfo
             mode: NetworkInfo.WlanMode;
             monitorNameChanges: true
             monitorSignalStrengthChanges: true
             monitorStatusChanges : true
             onNetworkSignalStrengthChanged: {
                 console.log("onNetworkSignalStrengthChanged:" +wlaninfo.networkSignalStrength )
             }
         }
         Text {
             id: signame
             //color: "white"
             text:  "["+wlaninfo.networkName +"]-["+wlaninfo.networkSignalStrength+"] = ["+wlaninfo.macAddress+"]";
             font.pixelSize: 22
             anchors.horizontalCenter: parent.horizontalCenter;
             anchors.verticalCenter: parent.verticalCenter;
         }
     }
    */

    Rectangle {
        width: 640
        height: 480
        color: "#343434"

        Item {
            id: wlan
            x:(parent.width / 2) - (parent.width / 4);
            y: parent.height / 2

            property int mode: NetworkInfo.WlanMode;

            NetworkInfo {
                id: wlaninfo
                //useMode: wlan.mode;
                mode: NetworkInfo.WlanMode;
                property string img : getImage(networkStatus);

                function getImage(newStatus) {
                    if(newStatus == "Connected") {
                        //return "images/wlan.svg";
                        return "image://theme/icon-m-common-clock";
                    }
                    if(newStatus == "Searching") {
                        //                    return "images/wlan.svg";
                    }
                    if(newStatus == "No Network Available") {
                        //return "images/wlan-noavail.svg";
                        return "image://theme/icon-m-content-sms";
                    }
                }

                onStatusChanged : {
                    img = getImage(newStatus)
                }
            }

            Component.onCompleted: {
                wlaninfo.startNameChanged();
                wlaninfo.startSignalStrengthChanged();
                wlaninfo.startStatusChanged();
                wlaninfo.startModeChanged();
            }

            Image {
                id: wifiimg
                source : wlaninfo.img;
                anchors.horizontalCenter: parent.horizontalCenter;
                anchors.verticalCenter: parent.verticalCenter;
            }

            Text {
                id: signalText
                color: "white"
                text: wlaninfo.networkSignalStrength
                anchors.top: wifiimg.bottom;
                anchors.horizontalCenter: parent.horizontalCenter;
            }


            Text {
                id: sigmstatus
                color: "white"
                text: wlaninfo.networkStatus;
                anchors.top: signalText.bottom;
                anchors.horizontalCenter: parent.horizontalCenter;
            }

            Text {
                id: signame
                color: "white"
                text:  wlaninfo.networkName;
                anchors.top: sigmstatus.bottom;
                anchors.horizontalCenter: parent.horizontalCenter;
            }

            Text {
                id: sigmac
                color: "white"
                text:  wlaninfo.macAddress;
                anchors.top: signame.bottom;
                anchors.horizontalCenter: parent.horizontalCenter;
            }
        }



    }

}
